To do this, Simple open your theme’s footer file and Just above to “</body>” tag paste any one of the below codes as per your requirements.
If you want all links (including your website links) to open in new tab, then use this code:
<script type=”text/javascript”>
$(document).ready(function(){
$(“body a[href^=’http://’]”).attr(“target”,”_blank”);
});
</script>
If you want external links to open in new tab, then use this code:
<script type=”text/javascript”>
$(document).ready(function() {
$(“a[href^=http]”).each(function(){
if(this.href.indexOf(location.hostname) == -1) {
$(this).attr({
target: “_blank”,
title: “Opens in a new window”
});
}
})
});
</script>
Save the theme and now open your website. Y0u can now see all URL(s) opening in new tab.